/**
 *
 */
package 队列;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import com.google.common.collect.Lists;

import jdk8.User;

/**
 * @Title:
 * @author zhoujie
 * @date 2019年4月2日 下午4:11:35 
 *
 */
public class BatchList {
    public static void main(String[] args) {
        List<User> collection = Arrays.asList(new User(1, "01"), new User(3, "03"), new User(3, "03"));
        List<List<User>> parts = Lists.partition(collection, 2);

        ExecutorService ES = Executors.newFixedThreadPool(15);
        List<Integer> list = new ArrayList<>();//原始的数据
        int total = 1002;//
        int batchSize = 1000;//拆分批数
        int batchCount = Math.max(total / batchSize, 1);
        for (int i = 0; i < batchCount; i++) {
            List<Integer> batchList = list.subList(i * batchSize, Math.min((i + 1) * batchSize, total));
            ES.submit(() -> {
                //自己写业务
                System.out.println(batchList);
            });
        }
    }


}
